{extend name="template/base" /}
{block name="style"}
<link rel="stylesheet" type="text/css" href="__LIB__/webuploader/0.1.5/webuploader.css" />
<link rel="stylesheet" type="text/css" href="__LIB__/fontawesome-4.2.0_ie7/4.2.0/css/font-awesome.min.css" />
<link rel="stylesheet" type="text/css" href="__LIB__/tags-input/dist/jquery.tagsinput.min.css" />
<link href="__LIB__/select2-4.0.3/dist/css/select2.min.css" rel="stylesheet" />
{/block}
{block name="content"}
<div class="page-container">
    <form class="form form-horizontal" id="form" method="post" action="{:\\think\\Request::instance()->baseUrl()}">
        <input type="hidden" name="id" value="{$vo.id ?? ''}">

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">标题：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="标题" name="title" value="{$vo.title ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">线路图片：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <!--dom结构部分-->
                <div id="main_img" class="uploader">
                    {php}
                    if($vo['main_img']){
                    $main_img_id=get_img_array($vo['main_img']);
                    }
                    {/php}
                    <!--用来存放item-->
                    <div  class="uploader-list fileList">
                        {volist name="main_img_id" id="main_img"}
                        <div id="main_img_{$main_img['id']}" class="file-item thumbnail upload-state-done">

                            <img width="100" height="100" src="{$main_img['url']}">
                            <div class="info">{$main_img['oname']}</div>
                            <div class="del fa fa-trash-o"> 删除 </div>
                            <input type="hidden" name="main_img[]" value="{$main_img['id']}">

                        </div>
                        <script>
                            window.onload=function(){
                                $('#main_img_{$main_img['id']}').on("click"," .del",function(){

                                    var $li = $('#main_img_{$main_img['id']}');
                                    $li.remove();
                                })
                            }
                        </script>
                        {/volist}
                    </div>
                    <div class="filePicker">选择图片</div>
                </div>
                <!--                <input type="number" class="input-text" placeholder="主图id" name="video_img_id" value="{$vo.video_img_id ?? ''}" >-->
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        {volist name="vo.route_products" id="route_product"}
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3 route_class">{$route_product.route_category_name}id：</label>
                <div class="formControls col-xs-6 col-sm-6">
                    <input type="text" class="product_ids tag" id="product_id" placeholder="{$route_product.route_category_name}id" name="product_id[]" value="{$route_product.product_id ?? ''}" >
                </div>
                <div class="col-xs-3 col-sm-3"></div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-3 col-sm-3">路线分类：</label>
                <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                    <select name="route_category_id[]" class="category_ids select2"  id="category_id" onchange="route_ids(this)">
                        {empty name = "$route_product.route_category_id"}
                        <option value="">选择路线分类</option>
                        {/empty}
                        {volist name="category_list" id="cl"}
                        <option {if ($route_product['route_category_id'] == $cl['id'])} selected {/if} value="{$cl.id}">{$cl.name}</option>
                        {/volist}
                    </select>
                </div>
                <div class="col-xs-3 col-sm-3"></div>
            </div>
        {/volist}

        <div class="product_id row cl" >
            <label class="form-label col-xs-3 col-sm-3">花儿产品：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <a class="btn btn-primary radius"  data-title="花儿产品" onclick="platform()" style="" ><i class="Hui-iconfont">&#xe600;</i> 花儿产品</a>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">出发时间：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text Wdate  " style="width:250px" autocomplete="off" placeholder="出发时间" name="go_time" value="{$vo.go_time ?date('Y-m-d',$vo['go_time']): ''}" {literal} onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})" {/literal} >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">路程时长：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" id="days" placeholder="请输入路程时长" name="days" value="{$vo.days ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">全程天数：</label>
            <div class="formControls col-xs-6 col-sm-6">
<!--                <input type="text" class="input-text" style="width: 80px" id="day" placeholder="全程天数" name="day" value="{$vo.day ?? ''}" >&nbsp;&nbsp;天-->
                <select name="day" class="select" style="width: 180px;height: 31px" id="isdeposit">
                    <option value="">请选择行程天数</option>
                    {foreach $day as $tian}
                        <option {if ($vo['day'] == $tian)} selected {/if} value="{$tian}" >{$tian}天</option>
                    {/foreach}
                </select>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">结束时间：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text Wdate  " style="width:250px" autocomplete="off" placeholder="结束时间" name="end_time" value="{$vo.end_time ?date('Y-m-d',$vo['end_time']):''}" {literal} onfocus="WdatePicker({dateFmt: 'yyyy-MM-dd'})" {/literal} >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">经过：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input type="text" class="input-text" placeholder="经过" name="pass" value="{$vo.pass ?? ''}" >
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">标签：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <input id="tag" type="text"  name="tag" class="tag" value="{$vo.tag ?? ''}" placeholder="路线标签" />

            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">内容：</label>
            <div class="formControls col-xs-6 col-sm-6">
                <script id="content" name="content" type="text/plain" style="height:100px;width: 100%;">{:htmlspecialchars_decode($vo.content)}</script>
             </div>
             <div class="col-xs-3 col-sm-3"></div>
         </div>
        <div class="row cl">
            <label class="form-label col-xs-3 col-sm-3">是否置顶：</label>
            <div class="formControls col-xs-6 col-sm-6 skin-minimal">
                <div class="radio-box">
                    <input type="radio" name="is_top" id="is_top-0" value="0">
                    <label for="is_top-0">否</label>
                </div>
                <div class="radio-box">
                    <input type="radio" name="is_top" id="is_top-1" value="1" datatype="*" nullmsg="请选择状态">
                    <label for="is_top-1">是</label>
                </div>
            </div>
            <div class="col-xs-3 col-sm-3"></div>
        </div>

        <div class="row cl">

            <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                <button type="submit" class="btn btn-primary radius">&nbsp;&nbsp;提交&nbsp;&nbsp;</button>
                <button type="button" class="btn btn-default radius ml-20" onClick="layer_close();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
            </div>
        </div>
    </form>
</div>
{/block}
{block name="script"}
<script type="text/javascript" src="__LIB__/select2-4.0.3/dist/js/select2.min.js"></script>
<script type="text/javascript" src="__LIB__/Validform/5.3.2/Validform.min.js"></script>
<script type="text/javascript" src="__LIB__/webuploader/0.1.5/webuploader.js"></script>
<script type="text/javascript" src="__LIB__/webuploader/0.1.5/image-upload/uploadimg.js"></script>
<script>window.UEDITOR_HOME_URL = '__LIB__/ueditor/1.4.3/'</script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/ueditor.all.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript" charset="utf-8" src="__LIB__/tags-input/dist/jquery.tagsinput.min.js"></script>

<!--时间插件-->
<script type="text/javascript" src="__LIB__/My97DatePicker/WdatePicker.js"></script>
<script>
    $(function () {

        $("[name='is_top'][value='{$vo.is_top ?? '0'}']").attr("checked", true);

        var id = $(".category_ids").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        // {notempty name = "category_id"}
        // id.val("{$category_id}").trigger("change");
        // {/notempty}

        upload_imgs("main_img");
        $("[name='autopay'][value='{$vo.autopay ?? '0'}']").attr("checked", true);
        $('.tag').tagsInput({width: 'auto', defaultText: "路线标签"});

        $('.product_ids').tagsInput({width: 'auto', defaultText: "产品id"});

        $('.skin-minimal input').iCheck({
            checkboxClass: 'icheckbox-blue',
            radioClass: 'iradio-blue',
            increaseArea: '20%'
        });
        var ue_content = UE.getEditor('content', {
            serverUrl: '{:\\think\\Url::build("Ueditor/index")}'
        });
        $("#form").Validform({
            tiptype: 2,
            ajaxPost: true,
            showAllError: true,
            callback: function (ret){
                ue_content.sync();
                ajax_progress(ret);
            }
        });
    });

    function route_ids(dom){
        console.log($(dom).find("option:selected").text())
        $(dom).parent().parent().prev().find(".route_class")[0].innerHTML=$(dom).find("option:selected").text()+"产品id：";
    }

    function platform(){
        var product_id = $(".product_id");
        var aa =  $(product_id).append(" <hr /><div class=\"row cl\">\n" +
            "            <label class=\"form-label col-xs-3 col-sm-3 route_class\" style=\"margin-left:8px; \" id='route_class' name='route_class'> 产品id：</label>\n" +
            "            <div class=\"formControls col-xs-6 col-sm-6\">\n" +
            "                <input type=\"text\" class=\"product_ids tag\"   placeholder=\"产品id\" name=\"product_id[]\" value=\"{$vo.product_id ?? ''}\" >\n" +
            "            </div>\n" +
            "            <div class=\"col-xs-3 col-sm-3\"></div>\n" +
            "        </div>\n" +
            "        <div class=\"row cl\"  >\n" +
            "            <label class=\"form-label col-xs-3 col-sm-3\" style=\"margin-left:8px; \">路线分类：</label>\n" +
            "            <div class=\"formControls col-xs-6 col-sm-6 skin-minimal\" >\n" +
            "                <select name=\"route_category_id[]\" class=\"category_ids select2\"  id=\"route_category_id[]\"  onchange=\"route_ids(this)\" >\n" +
            "                    <option  value=\"\">选择路线分类</option>\n" +
            "                    {volist name='category_list' id='cl'}\n" +
            "                    <option class='route_id' value='{$cl.id}'>{$cl.name}</option>\n" +
            "                    {/volist}\n" +
            "                </select>\n" +
            "            </div>\n" +
            "            <div class=\"col-xs-3 col-sm-3\"></div>\n" +
            "        </div>");

        $('.product_ids').tagsInput({width: 'auto', defaultText: "产品id"});

        var id = $(".category_ids").select2({
            language: "zh-CN", //设置 提示语言
            width: "100%", //设置下拉框的宽度
            theme: "classic"
        });
        // {notempty name = "category_ids"}
        // id.val("{$category_id}").trigger("change");
        // {/notempty}

    }
</script>


{/block}